import org.junit.Assert;
import org.junit.Test;

//import Transaction.Code;


public class TestTransaction {

	@Test
	public void testConstructorFourParameters() throws Exception
	{
		Transaction t = new Transaction(Transaction.Code.CREATE, "Sample Rental", DVD.Status.RENTAL, 1);
		Transaction compare = new Transaction(Transaction.Code.CREATE, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorThreeParameters() throws Exception
	{
		Transaction t = new Transaction(Transaction.Code.CREATE, "Sample Rental", DVD.Status.RENTAL);
		Transaction compare = new Transaction(Transaction.Code.CREATE, "Sample Rental", DVD.Status.RENTAL, 0, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorCode() throws Exception
	{
		Transaction t = new Transaction(Transaction.Code.CREATE);
		Transaction compare = new Transaction(Transaction.Code.CREATE, "", DVD.Status.RENTAL, 0, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorStringStatus() throws Exception
	{
		String record = "06 Sample Rental             001 S 001.00";
		Transaction t = new Transaction(record);
		Transaction compare = new Transaction(Transaction.Code.BUY, "Sample Rental", DVD.Status.SALE, 1, 1);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorStringReturn() throws Exception
	{
		String record = "02 Sample Rental             001 R 000.00";
		Transaction t = new Transaction(record);
		Transaction compare = new Transaction(Transaction.Code.RETURN, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorStringAdd() throws Exception
	{
		String record = "04 Sample Rental             001 R 000.00";
		Transaction t = new Transaction(record);
		Transaction compare = new Transaction(Transaction.Code.ADD, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorStringRemove() throws Exception
	{
		String record = "05 Sample Rental             001 R 000.00";
		Transaction t = new Transaction(record);
		Transaction compare = new Transaction(Transaction.Code.REMOVE, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testConstructorStringSell() throws Exception
	{
		String record = "07 Sample Rental             001 R 000.00";
		Transaction t = new Transaction(record);
		Transaction compare = new Transaction(Transaction.Code.SELL, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		
		Assert.assertTrue(t.equals(compare));
	}
	
	@Test
	public void testToString() throws Exception
	{
		Transaction t = new Transaction(Transaction.Code.RENT, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		String compare = "01 Sample Rental             001 R 000.00";
		
		Assert.assertEquals(t.toString(), compare);
	}
	
	@Test
	public void testEqualsFalse() throws Exception
	{
		Transaction t = new Transaction(Transaction.Code.CREATE, "Sample Rental", DVD.Status.RENTAL, 1, 0);
		Transaction compare = new Transaction(Transaction.Code.CREATE, "Sample Sale", DVD.Status.RENTAL, 1, 0);
		
		Assert.assertFalse(t.equals(compare));
	}
	
}